#ifndef COMMONCONTAINER_CPP
#define COMMONCONTAINER_CPP

#include <QWidget>
#include <QVBoxLayout>
#include <QLabel>
#include <QPushButton>
#include <QPaintEvent>
#include <QResizeEvent>
#include <QPainter>

class CommonContainer : public QWidget
{
    Q_OBJECT
public:
    explicit CommonContainer(const QString &title, bool hasEditBtn = false, int bgType = 2, QWidget *parent = nullptr);
    ~CommonContainer();

    // 编辑模式控制
    void setEditMode(bool enabled);
    bool isEditMode() const;

signals:
    void editButtonClicked();
    void editModeChanged(bool enabled);

protected:
    void setContentWidget(QWidget *contentWt);
    void setContentLayout(QLayout *contentLayout);

    void paintEvent(QPaintEvent *event) override;
    void resizeEvent(QResizeEvent *event) override;

private slots:
    void onEditButtonClicked();

private:
    void setupUI();

private:
    QVBoxLayout *m_mainLayout;

    QWidget *m_topWt;
    QLabel *m_titleLabel;
    QPushButton *m_editButton;
    bool m_isEditMode;
    int m_bgType;
};

#endif